
class AliLogTracker {
    params_: string[];
    uri_: string;
    constructor(host: string, project: string, logstore: string) {
        this.uri_ = 'https://' + project + '.' + host + '/logstores/' + logstore + '/track?APIVersion=0.6.0';
        this.params_ = new Array();
    }
    push(key: string, value: any) {
        if (!key) {
            return;
        }
        if (value === '') {
            return;
        }
        this.params_.push(key);
        this.params_.push(value);
    }
    claer() {
        this.params_ = []
    }

    logger() {
        if (process.env.NODE_ENV === 'production') {
            let url = this.uri_;
            this.params_.forEach((v, k) => {
                if (k % 2 == 0) {
                    url += '&' + encodeURIComponent(v);
                } else {
                    url += '=' + encodeURIComponent(v);
                }
            })
            try {
                uni.request({
                    url: url
                })
            } catch (e: any) {

            }
        }

    }
}

export default AliLogTracker;